<include file="../Public/header" />
<script data-main="__PUBLIC__/admin/js/page/admin/goods/addgoods" src="__PUBLIC__/admin/js/lib/requirejs/require.js"></script>
</head>
<body>
  <div class="page">
    <div class="page-hd">
      <if condition="isset($res)">
        <h1>编辑商品</h1>
        <else />
        <h1>新增商品</h1>
      </if>
    </div>
    <div class="form">
      <form action="{:URL('admin/Goods/doaddGoods')}" id="J_form" method="post" enctype="multipart/form-data">
        <input type="hidden" value="{$goods.id}" name="id" />
       <dl class="kv">
         <dt>
            <label>商品名称：</label>
          </dt>
          <dd>
            <input class="input-text" type="text" name="name" value="{$goods.name}" required/>
            <span class="required">*</span>
            <div class="kv-error"></div>
          </dd>
        </dl>
       <dl class ="kv">
            <dt >商品分类 </dt>
            <dd >
               <select name ="cate_id" class ="J_tbcats">
                   <option value ="0">--请选择--</option>
                   <volist name ="item_cate" id="cate">
                   <option value= "{$cate.id}" 
                    <php>if($goods['cate_id']== $cate['id']){echo 'selected ="selected"';} </php>
                   >--{$cate.name}-- </option>
                   </volist>
               </select>
               <input type ="hidden" id="J_pid" name= "pid" val= "">
               <span class ="gray ml10"></ span>
            </dd>
          </dl>
        <dl class="kv">
          <dt>
            <label>商品状态：</label>
          </dt>
          <dd>
        <select name="is_del" id="is_del">
          <option value="3">新增商品</option>
          <option value="0" <eq name='goods.is_del' value='0'>selected</eq>>上线商品</option>
          <option value="3" <eq name='goods.is_del' value='3'>selected</eq>>新增商品</option>
        </select> 
          
          </dd>
        </dl>
        <dl class="kv">
          <dt>
            <label>商品价格：</label>
          </dt>
          <dd>
            <input class="input-text" type="text" name="price" value="{$goods.price}" />
          </dd>
        </dl>
        <dl class="kv">
          <dt>
            <label>商品链接地址：</label>
          </dt>
          <dd>
            <input class="input-text" type="text" name="detail_url" value="{$goods.detail_url}" />
          </dd>
        </dl>
        </dl>
         <dl class="kv">
          <dt>
            <label>商品数量：</label>
          </dt>
          <dd>
            <input class="input-text" type="text" name="num" value="{$goods.num}" />
          </dd>
        </dl>
        <dl class="kv">
        <dt>
          <label>商品图片列表上传：</label>
        </dt>
        <dd>
          <input type="hidden" id="pic_ischange" name="pic_ischange" value="" />
          <div id="J_imageUpload">
            <volist name="goods.imgs" id="pictures">
              <div  id ="imgs">
              <input type="hidden" name="imgs[]" value="{$pictures}" class="input-text">
              <img  style="margin:5px; opacity:1;width:100px;height:100px" src="{$pictures}"  />
              <a href="javascript:removePic('{$pictures}')" onclick="$(this).parent().remove();">删除</a>
              </div>
              <br/>
            </volist>
          </div>
          <input type="button" class="btn" value="选择文件" id="J_selectPic" />
          
        </dd>
      </dl>
        <dl class="kv">
          <dt>
            <label>商品描述：</label>
          </dt>
          <dd>
            <textarea name="desc" rows="8" cols="100">{$goods.desc}</textarea>
          </dd>
        
        
        <div class="actions">
          <if condition="isset($goods)">
            <input class="btn btn-y" type="submit" value="{$Think.lang.update}商品" />
            <else />
            <input class="btn btn-y" type="submit" value="{$Think.lang.add}商品" />
          </if>
          <a href="{:URL('admin/Goods/goodsList')}&status={$goods['is_del']}" class="btn btn-n">{$Think.lang.cancel}</a>
        </div>
      </form>
    </div>

  </div>
  <script type="text/javascript">
  function removePic(pic_url){
       html  = '<input type="hidden" name="del_imgs[]" value="' + pic_url + '" class="input-text">'
       $('#J_imageUpload').append(html) 
	   }
  </script>
  
  
  
</body>

</html>
